package com.itheima.反射reflect.reflectHashMap;

import java.lang.reflect.Field;
import java.util.HashMap;

//基于反射方式获取hashMap的加载因子并打印
public class ReflectHashMapDemo {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchFieldException {
            //获取HashMap的字节码文件对象     --类对象
        Class clazz = Class.forName("java.util.HashMap");
        //创建一个HashMap对象
        HashMap hm = (HashMap) clazz.newInstance();

        Field field = clazz.getDeclaredField("DEFAULT_LOAD_FACTOR");
        field.setAccessible(true);
        Object o = field.get(hm);
        System.out.println(o);
    }
}
